<%@ include file="IsStudent.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../master/head.jsp"%>
</head>
<body>
<div id="container">
<div id="wrapper">
<div id="sidebar">
<div id="sb_top"><%@ include file="../master/sbTop.jsp"%>
</div>
<script>
            function isCorrect(t)
            {
				inno = document.getElementById('incorrectFields');
                if (t.fn.value == '' )					
				{	inno.innerHTML = 'Invalid First Name';return false;}
				else if ( t.mn.value == '' )
				{	inno.innerHTML = 'Invalid Father Name';return false;}
				else if ( t.ln.value == '' )
				{	inno.innerHTML = 'Invalid Last Name';return false;}
				else if ( t.pwd.value == '' )
				{	inno.innerHTML = 'Invalid Password';return false;}
				else if ( t.pwd.value != t.rpwd.value)
				{	inno.innerHTML = 'Passwords not matches.';return false;}
				else if ( !isEmail(t.email.value) )
				{	inno.innerHTML = 'Invalid Email';return false;}
				else	
					 {
					return true;
					 }

            }
            function isEmail(t)
            {
				if (t.indexOf('.') > t.indexOf('@')+1 && t.indexOf('@') > 0)
					 return true;
				  else
					   return false;
              }
        </script>

<div class="sb_content"><!--##########--> <!-- Start Menu --> <%@ include
	file="../master/studentMenu.jsp"%> <!-- Profile -->
<%@ include file="../master/profile.jsp"%> <!-- links -->
<%@ include file="../master/links.jsp"%>
<div class="copyright"><%@ include file="../master/copyright.jsp"%>
</div>

</div>
<!-- /sb_content --></div>
<!-- /sidebar --> <!-- Top -->
<div id="header"><%@ include file="../master/header.jsp"%>
</div>


<!-- Start main content -->
<div id="content">
<div id="intro">
<div class="intro_t">
<h1><span>..</span>Welcome to<span>..</span></h1>
<h2>student project managment system</h2>

</div>
</div>
<!-- /intro --> <%@ page import="java.sql.*,database.*"%>

<%
try{   
    DBCon db = new DBCon();
     
    String control = db.getControlValue("student_update");
                
    ResultSet res = new DBCon().getStudent(",userlogin WHERE student.username = userlogin.username and ID ="+session.getAttribute("id"));
        
	if (res.next())
        {
		String gpa = res.getString("GPA");
		String user = res.getString("student.username");
		String pass = res.getString("password");
        %>
<form name="UpdateProfile" action="updateProfile.jsp" method="post" onsubmit="return isCorrect(this)">
<table border="0" id="tabM">
	<tr>
		<td class="style1">
		<font style="width: 97%; clear: both;  margin-top: 20px; margin-bottom: 10px; padding-bottom: 3px;   letter-spacing: -1px;  font: 2em arial, helvetica, sans-serif;  color: #877065;  background-color: transparent;  border-bottom: 4px solid #877065;">Student Information</font>
                 
                                        <%
                                          if(control.equals("true"))
                                            {
                                         
                                         %>
		</td>
		 									<td>
										<div id='incorrectFields' class='required'></div>
									</td>

	</tr>
	<tr>
		<td>
		<hr />
		</td>
		<td>
		<hr />
		</td>
	</tr>
	<tr>
		<td>First Name</td>
		<td><input type="text" name="fn" size="30"
			value="<%= res.getString("FirstName")%>" /></td>
	</tr>
	<tr>
		<td>Middle Name</td>
		<td><input type="text" name="mn" size="30"
			value="<%= res.getString("FatherName")%>" /></td>
	</tr>
	<tr>
		<td>Last Name</td>
		<td><input type="text" name="ln" size="30"
			value="<%= res.getString("LastName")%>" /></td>
	</tr>
	<tr>
		<td>GPA</td>
		<td>
			 <input type="text" size="30" value="<%= gpa %>" disabled/>
			 <input type="hidden" name="GPA" value="<%= gpa %>"/>
			 </td>
	</tr>
	<tr>
		<td>Affiliation</td>
		<td><select name="aff">
                     <% String temp = res.getString("Aff"); 
                     if (temp.equals("ma"))
                        { out.println("<option name='s' value='ma' selected>Male</option> ");
                         out.println("<option name='s' value='fm' >Female</option> ");}
                     else{
                         out.println("<option name='s' value='fm' selected>Female</option> ");
                     out.println("<option name='s' value='ma'>Male</option> ");
                         }
                     %>
		</select></td>
	</tr>
	<tr>
		<td>Mobile Phone</td>
		<td><input type="text" name="mp" size="30"
			value="<%= res.getString("mobilePhone")%>" /></td>
	</tr>
	<tr>
		<td>Email</td>
		<td><input type="text" name="email" size="30"
			value="<%= res.getString("email")%>" /></td>
	</tr>
	<tr>
		<td>
		<hr />
		</td>
		<td>
		<hr />
		</td>
	</tr>
	<tr>
		<td class="style1">
		<h2>User Account</h2>
		</td>
	</tr>
	<tr>
		<td>Login</td>
		<td><input disabled type="text" size="15" value="<%= user %>" />
			 <input type="hidden" name="login" value="<%= user %>" />
			 </td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="password" name="pwd" size="15"
			value="<%= pass %>" /></td>
	</tr>
	<tr>
		<td>Re-Password</td>
		<td><input type="password" name="rpwd" size="15" value="<%= pass %>"/></td>
	</tr>
	<tr>
		<td><input type="submit" value="Update Profile" /></td>
		<td></td>
	</tr>
</table>
</form>
                                         <%
}
else
{
%>
    </td>
	</tr>
</table>
</form>
        <br/><br/><center><h2>Update Profile is not available</h2></center>
<%}

        }
    }
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}

%>
</div>
<!-- /content --></div>
<!-- /wrapper -->
<div class="clear">&nbsp;</div>
<!-- Important! Fix the problem of height in Firefox --></div>
<!-- /Container -->


</body>
</html>